package hms.permissions;

import hms.UserAccountsModule.UserAccount;
import hms.properties.Properties;

public class PermissionTestCase {

	public static void main(String[] args) {
		/* IGNORE THIS.  This is init code that will be handled by the
		 * MainController when the user authenticates.
		 */
		Properties.currentUser = new UserAccount();
		Properties.currentUser.setUsername("ppanther");
		PermissionSet testPS = new PermissionSet();
		testPS.grantPermission(Permission.ADMINISTER_USERS);
		testPS.grantPermission(Permission.OFFER_ADDITIONAL_GUEST_SERVICES);
		Properties.currentUser.setPermissions(testPS);
		/* END IGNORE
		 * Pounce Panther is an employee who can administer user accounts and offer
		 * additional guest services to guests.
		 */
		
		System.out.println("Pounce Panther's Permissions:");
		System.out.println("-----------------------------");
		// For loop to dump all permissions
		for(Permission p : Permission.values()) {
			// Permission.toString has been overwritten, bout you shouldn't need it
			// Here is a proof of concept
			System.out.printf("Permission [%s] is %b.\n", p,
					Properties.currentUser.isPermissionGranted(p));
		}
		
		/* PAY ATTENTION HERE!!!!!!
		 * This is what a permission check should look like.
		 * 
		 * All permissions are included in the enum class Permission.
		 * 
		 */
		System.out.println();
		System.out.println("Attempting to offer additional guest services... ");
		if(Properties.currentUser.isPermissionGranted(Permission.OFFER_ADDITIONAL_GUEST_SERVICES)) {
			System.out.println("\tAccess GRANTED");
		} else {
			System.out.println("\tAccess DENIED");
		}
	}
}
